package com.snape.dao;

import com.snape.entity.User;
import com.snape.entity.User_Room;
import org.apache.ibatis.annotations.Param;

import java.util.ArrayList;

/**
 * Created by liuqingcan_snape on 2017/3/28.
 */

//@Repository
public interface UserDao {
    /**
     * 下列Api是和Use表相关操作
     */

    /**
     * 根据用户名查询User实体
     * @param name
     * @return User 实体
     * @throws Exception
     */
    public User queryByUserName (String name) throws Exception;

    /**
     * 根据主键查询User实体
     * @param id
     * @return User 实体
     * @throws Exception
     */
    public User queryById (int id) throws Exception;

    /**
     * 插入新User
     * @param user
     * @throws Exception
     */
    public void insertUser(@Param("user") User user) throws Exception;

    /**
     * 更新User表
     * @param user
     * @throws Exception
     */
    public void updateUser(@Param("user") User user) throws Exception;

    /**
     * 更新user表中的 cookie 字段
     * @param cookie
     * @throws Exception
     */
    public void updateUserCookie(@Param("cookie") String cookie,@Param("userId") int userid) throws Exception;

    /**
     * 查找 user表中的 cookie 字段
     * @param userid
     * @return
     * @throws Exception
     */
    public String selectUserCookie(@Param("userId") int userid) throws Exception;

    /**
     * 查找最新的id
     * @return
     * @throws Exception
     */
    public Integer selectLastId() throws Exception;




    /**
     * 下列Api是和User_Video表相关操作
     */
    /**
     * 表名有问题,在设计api的时候已经改正了,特此记录
     * no: user_videos    yes: user_rooms
     * no: video_category yes: room_category
     */



    /**
     * 查询出User_video实体所有属性
     * @param userid
     * @param roomid
     * @return User_Room 实体
     * @throws Exception
     */
    public ArrayList<User_Room> queryStatusOfUserToVideo(@Param("userId") int userid, @Param("roomId")int roomid)
            throws Exception;

    /**
     * 查询该用户的状态
     * @param userid
     * @return
     * @throws Exception
     */
    public ArrayList<User_Room> queryStatusOfUser(@Param("userId") int userid) throws Exception;


    /**
     * 用户是否收藏该课程,默认为0:未收藏
     * @param userid
     * @param roomid
     * @throws Exception
     */
    public void updateCollectionStatus (@Param("userId") int userid,@Param("roomId")int roomid) throws Exception;

    /**
     * 用户是否观看该课程,默认为0:未观看
     * @param userid
     * @param roomid
     * @throws Exception
     */
    public void updateRecordsStatus (@Param("userId") int userid,@Param("roomId")int roomid) throws Exception;

    /**
     * 用户是否直播,默认为0:直播,1:录播
     * @param userid
     * @param roomid
     * @throws Exception
     */
    public void updateWebcastingStatus (@Param("userId") int userid,@Param("roomId")int roomid) throws Exception;

    /**
     *插入主播直播地址
     * @param userid
     * @param roomid
     * @throws Exception
     */
    public void insertLiveAddress (@Param("userId") int userid,@Param("roomId")int roomid,
                                   @Param("address") String add) throws Exception;

    /**
     * 插入一个新的user_room数据
     * @param user_room
     * @throws Exception
     */
    public void insertUserToVideo(@Param("ur") User_Room user_room) throws Exception;
}